home *** CD-ROM | disk | FTP | other *** search
/ Programmer Power Tools / Programmer Power Tools.iso / progjrn / pj_6_6.arc / LISTING.1 < prev    next >
Text File  |  1988-08-30  |  2KB  |  49 lines

  1.   1  /*
  2.   2   * dosexec.c    -----   Spawns a synchronous OS/2 process
  3.   3   */
  4.   4  
  5.   5  #include <doscall.h>
  6.   6  #include <stdio.h>
  7.   7  #include <string.h>
  8.   8  
  9.   9  #define WAIT                (unsigned) 0
  10.  10  #define NO_WAIT_DONT_CARE   (unsigned) 1
  11.  11  #define NO_WAIT_CARE        (unsigned) 2
  12.  12  #define PTRACE              (unsigned) 3
  13.  13  #define DAEMON              (unsigned) 4
  14.  14  
  15.  15  char FailString[64];                /* Place for name of load object on error */
  16.  16  char far *FSptr = FailString;       /* Ptr to Fail String buffer */
  17.  17  unsigned FSLength = sizeof FailString;  /* Length of failure string */
  18.  18  unsigned ExecType;                  /*  Wait,
  19.  19                                          NoWaitDontCare, NoWaitCare,
  20.  20                                          Ptrace,
  21.  21                                          Daemon */
  22.  22  char ArgString[64];                 /* Argument string */
  23.  23  char far *ASptr = ArgString;        /* Far ptr needed for DosExecPgm() */
  24.  24  char EnvString[64];                 /* Environment Space string */
  25.  25  char far *ESptr = EnvString;        /* Far ptr needed for DosExecPgm() */
  26.  26  char Pgm[64];                       /* Program to be exec'ed */
  27.  27  char far *Pptr = Pgm;               /* Far ptr needed for DosExecPgm() */ 
  28.  28  
  29.  29  struct ResultCodes RetCode;         /* For return code from DosExecPgm() */
  30.  30  struct ResultCodes far *RCptr = &RetCode;
  31.  31  
  32.  32  main()
  33.  33  {
  34.  34      char *offset;
  35.  35  
  36.  36      strcpy(Pgm, "frank.exe");       /* Want to  run 'frank.exe' */
  37.  37      ESptr = (char far *) NULL;      /* Inherit Parent's environment */
  38.  38  
  39.  39      strcpy(ArgString, "frank.exe"); /* First string is pgm name */
  40.  40  
  41.  41      offset = ArgString + strlen("frank.exe");
  42.  42      *offset = NULL;                 /* Separate the two strings */
  43.  43      strcpy(offset+1, "-d file");    /* Second string - the cmd line arguments */
  44.  44  
  45.  45  /* Now that everything is setup...go and do it. */
  46.  46  
  47.  47      DosExecPgm(FSptr, FSLength, WAIT, ASptr, ESptr, RCptr, Pptr);
  48.  48  }
  49.